<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 有一个数组，里面是一个又一个对象，对象有个属性 id 用来去重
      const arr = [
        { id: 0, title: '第0' },
        { id: 1, title: '第1' },
        { id: 0, title: '第0' },
        { id: 2, title: '第2' },
        { id: 0, title: '第0' },
        { id: 0, title: '第0' },
        { id: 3, title: '第3' },
        { id: 0, title: '第0' },
        { id: 0, title: '第0' }
      ]

      var newArr = {}
      arr.forEach(item => {
        newArr[item.id] = item
      })
      console.log(newArr)
    </script>
  </body>
</html>
